package com.heiyu.task;

import com.heiyu.dao.UserInfoMapper;
import com.heiyu.entity.UserInfo;
import com.heiyu.utils.CacheKey;
import com.heiyu.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class VerifyPhoneClearTask {

    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private RedisUtils redisUtils;

    //@Scheduled(cron = "59 59 23 * * ?")
    @Scheduled(fixedDelay = 5000)
    public void execute(){
        List<UserInfo> list = userInfoMapper.selectList(new UserInfo());
        for(UserInfo userInfo:list){
            redisUtils.del(CacheKey.VERIFY_CODE_CAL + userInfo.getTelphone());
        }

    }
}
